//
// Decompiled by Jadx - 454ms
//
package gc;

import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Switch;
import android.widget.TextView;
import androidx.activity.b;
import androidx.appcompat.app.t;
import androidx.constraintlayout.widget.i;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;
import fi.e;
import fi.k;
import fi.m;
import fi.w;
import fn.j;
import fn.y;
import fo.c;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import me.plusne.Adapter.Login.g;
import me.plusne.GreenDao.dao.SoulVoiceCollectDao;
import me.plusne.common.Http.Hook;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.Soul.JsonSelectUser;
import me.plusne.common.Json.Soul.Photo4PhotoBean;
import org.luckypray.dexkit.query.matchers.FieldMatcher;
import r.f;

public final class ay extends XC_MethodReplacement {
    public static final int a = 0;
    public final aw b;

    public ay(aw awVar) {
        this.b = awVar;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to find 'out' block for switch in B:6:0x005f. Please report as an issue. */
    /* JADX WARN: Removed duplicated region for block: B:95:0x038d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object replaceHookedMethod(XC_MethodHook.MethodHookParam methodHookParam) {
        Object dr;
        Object obj;
        String str;
        int intField;
        f i;
        String str2;
        Object obj2;
        Photo4PhotoBean photo4PhotoBean;
        if (methodHookParam.args[0].getClass().getName().equals(y.cj("Im"))) {
            Object[] objArr = methodHookParam.args;
            if (objArr.length > 5) {
                Object obj3 = objArr[0];
                aw awVar = this.b;
                awVar.ct = obj3;
                Object obj4 = objArr[objArr.length - 2];
                int intField2 = XposedHelpers.getIntField(obj4, c.p(FieldMatcher.create().declaredClass(obj4.getClass()).type(Integer.TYPE).modifiers(16)).getFieldName());
                String as = j.as(awVar.ct, "msgId");
                switch (intField2) {
                    case 200:
                        Object dr2 = z.dr(awVar.ct);
                        if (XposedHelpers.getIntField(dr2, "msgType") != 1) {
                            return null;
                        }
                        Object obj5 = ((HashMap) XposedHelpers.getObjectField(dr2, "maps")).get("MSGCONTENT");
                        String as2 = obj5 != null ? j.as(obj5, "text") : null;
                        if (TextUtils.isEmpty(as2)) {
                            return null;
                        }
                        w wVar = new w(y.by.getActivity());
                        wVar.bj(fi.e.INPUT_MULTI);
                        wVar.aj = "修改聊天记录";
                        wVar.bb();
                        wVar.k = as2;
                        wVar.w = new g(this, as, obj5, 2);
                        wVar.bk();
                        return null;
                    case 201:
                    case 202:
                    case 205:
                        String str3 = (String) XposedHelpers.getObjectField(((HashMap) XposedHelpers.getObjectField(z.dr(awVar.ct), "maps")).get("MSGCONTENT"), "imageUrl");
                        if (!TextUtils.isEmpty(str3)) {
                            if (intField2 == 201) {
                                j.ai(str3);
                                f i2 = f.i();
                                i2.n();
                                i2.l("已复制图片URL剪:" + str3);
                            } else if (intField2 == 202) {
                                r.g.p(y.by.getActivity(), str3);
                            } else if (intField2 == 205) {
                                long currentTimeMillis = System.currentTimeMillis();
                                Activity activity = y.by.getActivity();
                                StringBuilder sb = new StringBuilder("Expression_");
                                sb.append(currentTimeMillis);
                                sb.append(str3.endsWith(".gif") ? ".gif" : ".png");
                                fn.g.c(activity, str3, sb.toString());
                            }
                        }
                        return null;
                    case 203:
                    case 204:
                    case 206:
                    case 207:
                        j.bn(awVar.ct, "from", z.eb());
                        if (!(intField2 == 203 || intField2 == 204 || intField2 == 207) || (dr = z.dr(awVar.ct)) == null || (obj = ((HashMap) XposedHelpers.getObjectField(dr, "maps")).get("MSGCONTENT")) == null) {
                            intField = 0;
                            str = null;
                        } else {
                            str = (String) XposedHelpers.getObjectField(obj, "url");
                            intField = XposedHelpers.getIntField(obj, "duration");
                        }
                        switch (intField2) {
                            case 203:
                                if (TextUtils.isEmpty(str)) {
                                    return null;
                                }
                                j.ai(str);
                                f i3 = f.i();
                                i3.n();
                                i3.l("已复制到剪贴板:" + str);
                                return null;
                            case 204:
                                if (TextUtils.isEmpty(str)) {
                                    return null;
                                }
                                fn.g.c(y.by.getActivity(), str, "Voice_" + j.as(awVar.ct, "msgId") + ".m4a");
                                return null;
                            case 206:
                                if (j.ae("longToMessage")) {
                                    Object dr3 = z.dr(awVar.ct);
                                    List list = (List) z.dj(j.ak("cn.soulapp.android.component.square.service.ChatService"), "getRecentConversationList", new Object[0]);
                                    ArrayList arrayList = awVar.cw;
                                    arrayList.clear();
                                    if (list != null) {
                                        for (Object obj6 : list) {
                                            Object objectField = XposedHelpers.getObjectField(obj6, c.p(FieldMatcher.create().declaredClass(obj6.getClass()).type("cn.soulapp.android.client.component.middle.platform.model.api.user.ImUserBean")).getFieldName());
                                            if (objectField != null) {
                                                String as3 = j.as(objectField, "avatarName");
                                                String as4 = j.as(objectField, "alias");
                                                String as5 = j.as(objectField, "userIdEcpt");
                                                StringBuilder k = b.k(j.as(objectField, "signature"));
                                                k.append(TextUtils.isEmpty(as4) ? "" : b.i("(", as4, ")"));
                                                String sb2 = k.toString();
                                                String dm = z.dm(as5);
                                                JsonSelectUser jsonSelectUser = new JsonSelectUser();
                                                jsonSelectUser.setName(sb2);
                                                jsonSelectUser.setUserID(dm);
                                                jsonSelectUser.setAvatarName(as3);
                                                jsonSelectUser.setCheckBox(false);
                                                jsonSelectUser.setUserIdEcpt(as5);
                                                arrayList.add(jsonSelectUser);
                                            }
                                        }
                                        JsonHookStatic jsonHookStatic = y.by;
                                        w wVar2 = new w(jsonHookStatic.getActivity());
                                        wVar2.bj(fi.e.VIEW);
                                        View inflate = LayoutInflater.from(jsonHookStatic.getActivity()).inflate(-2113142696, (ViewGroup) null, false);
                                        int i4 = 0x7f820098;
                                        TextView textView = (TextView) i.cg(0x7f820098, inflate);
                                        if (textView != null) {
                                            i4 = 0x7f82009f;
                                            TextView textView2 = (TextView) i.cg(0x7f82009f, inflate);
                                            if (textView2 != null) {
                                                i4 = 0x7f82010c;
                                                ListView listView = (ListView) i.cg(0x7f82010c, inflate);
                                                if (listView != null) {
                                                    i4 = 0x7f82015f;
                                                    TextView textView3 = (TextView) i.cg(0x7f82015f, inflate);
                                                    if (textView3 != null) {
                                                        i4 = 0x7f8201db;
                                                        Switch r18 = (Switch) i.cg(0x7f8201db, inflate);
                                                        if (r18 != null) {
                                                            cc.f fVar = new cc.f((LinearLayout) inflate, textView, textView2, listView, textView3, r18);
                                                            ListAdapter fVar2 = new fh.f(jsonHookStatic.getActivity(), arrayList, new k(8, fVar));
                                                            ((ListView) fVar.f).setAdapter(fVar2);
                                                            ((Switch) fVar.g).setOnCheckedChangeListener(new au(awVar, fVar2));
                                                            r.e.d(-2113535903, 25.0f, (TextView) fVar.d);
                                                            r.e.d(-2113535903, 25.0f, (TextView) fVar.c);
                                                            ((TextView) fVar.c).setOnClickListener(new m(2, wVar2));
                                                            ((TextView) fVar.d).setOnClickListener(new fg.m(awVar, fVar2, wVar2, dr3, 1));
                                                            wVar2.ar = fVar.h();
                                                            wVar2.bk();
                                                            return null;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i4)));
                                    }
                                    i = f.i();
                                    i.j();
                                    str2 = "没有获取到联系人";
                                } else {
                                    i = f.i();
                                    i.j();
                                    str2 = "请先打开设置(长按聊天消息转发消息)";
                                }
                                i.l(str2);
                                return null;
                            case 207:
                                JsonHookStatic jsonHookStatic2 = y.by;
                                if (jsonHookStatic2.getDb() != null) {
                                    SoulVoiceCollectDao soulVoiceCollectDao = jsonHookStatic2.getDb().y;
                                    soulVoiceCollectDao.getClass();
                                    a.g gVar = new a.g(soulVoiceCollectDao);
                                    gVar.l(SoulVoiceCollectDao.Properties.Url.f(str), new a.i[0]);
                                    if (gVar.h() > 0) {
                                        f i5 = f.i();
                                        i5.k();
                                        i5.l("已收藏过了");
                                        return null;
                                    }
                                    w wVar3 = new w(jsonHookStatic2.getActivity());
                                    wVar3.bj(fi.e.INPUT);
                                    wVar3.aj = "输入语音备注";
                                    wVar3.bb();
                                    wVar3.w = new b(str, intField);
                                    wVar3.bk();
                                }
                                return null;
                        }
                    case 208:
                        Object dr4 = z.dr(awVar.ct);
                        if (dr4 != null && (obj2 = ((HashMap) XposedHelpers.getObjectField(dr4, "maps")).get("MSGCONTENT")) != null && obj2.getClass().getName().equals("cn.soulapp.imlib.msg.chat.JsonMsg") && Objects.equals(j.as(obj2, "messageType"), "exchange_image") && (photo4PhotoBean = (Photo4PhotoBean) b.c(j.as(obj2, "content"), Photo4PhotoBean.class)) != null) {
                            r.g.p(y.by.getActivity(), photo4PhotoBean.getImageUrl());
                        }
                        return null;
                    case 209:
                        j.ah(awVar.ct);
                        f i6 = f.i();
                        i6.n();
                        i6.l("已复制到剪贴板");
                        break;
                    case 210:
                        String u = r.g.u(z.dv(awVar.ct));
                        if (TextUtils.isEmpty(u)) {
                            b.u("没有可翻译的文本");
                            return null;
                        }
                        JsonHookStatic jsonHookStatic3 = y.by;
                        fi.y.f(jsonHookStatic3.getActivity(), "正在翻译...");
                        a aVar = new a(jsonHookStatic3.getActivity());
                        if (jsonHookStatic3.getUserInfo() != null) {
                            t.c().j(((Hook) dq.b.b(Hook.class)).Translate(u).subscribeWith(aVar));
                            break;
                        }
                        break;
                }
            }
        }
        return j.w(methodHookParam);
    }
}
